package yevgeniy.melnichuk.selenium;

import yevgeniy.melnichuk.selenium.worker.ClickAndWaitSeleniumWorker;
import yevgeniy.melnichuk.selenium.worker.ClickSeleniumWorker;
import yevgeniy.melnichuk.selenium.worker.IsTextPresentSeleniumWorker;
import yevgeniy.melnichuk.selenium.worker.OpenSeleniumWorker;
import yevgeniy.melnichuk.selenium.worker.SleepSeleniumWorker;
import yevgeniy.melnichuk.selenium.worker.TypeSeleniumWorker;

import com.thoughtworks.selenium.Selenium;

public class SeleniumBuilder {
	private static final int DEFAULT_WAIT_FOR_PAGE = 20;

	private Selenium selenium;

	public SeleniumBuilder(Selenium selenium) {
		this.selenium = selenium;
	}

	public SeleniumBuilder type(String q, String value) {
		new TypeSeleniumWorker(selenium, q, value).run();
		return this;
	}

	public SeleniumBuilder click(String q) {
		new ClickSeleniumWorker(selenium, q).run();
		return this;
	}

	public SeleniumBuilder clickAndWait(String q) {
		new ClickAndWaitSeleniumWorker(selenium, q, DEFAULT_WAIT_FOR_PAGE).run();
		return this;
	}

	public SeleniumBuilder sleep(int sek) {
		new SleepSeleniumWorker(selenium, sek).run();
		return this;
	}

	public SeleniumBuilder isTextPresent(String text) {
		new IsTextPresentSeleniumWorker(selenium, text).run();
		return this;
	}

	public SeleniumBuilder open(String url) {
		new OpenSeleniumWorker(selenium, url).run();
		return this;
	}
}
